package com.starsoft.trade.bean;

import java.util.Date;
import java.util.List;

public class TradeAcountStatus {

	private TradeAcount tradeAcount;
	
	private TradeSummary summary;
	
	private List<TradePosition> positions;

	public TradeAcountStatus(TradeAcount tradeAcount, TradeSummary summary, List<TradePosition> positions) {
		super();
		this.tradeAcount = tradeAcount;
		this.summary = summary;
		this.positions = positions;
	}

	public Date getAsofDate(){
		return summary.getId().getAsofdate();
	}
	
	public Integer getAcountId(){
		return tradeAcount.getAcountId();
	}
	
	public TradeAcount getTradeAcount() {
		return tradeAcount;
	}

	public void setTradeAcount(TradeAcount tradeAcount) {
		this.tradeAcount = tradeAcount;
	}

	public TradeSummary getSummary() {
		return summary;
	}

	public void setSummary(TradeSummary summary) {
		this.summary = summary;
	}

	public List<TradePosition> getPositions() {
		return positions;
	}

	public void setPositions(List<TradePosition> positions) {
		this.positions = positions;
	}
	
	public TradePosition getPosition(String secId){
		for(TradePosition pos : positions){
			if(pos.getId().getSecId().equals(secId)){
				return pos;
			}
		}
		return null;
	}
	
	@Override
	public String toString() {
		try {
			StringBuilder sb = new StringBuilder("\n##### trade acount status ####\n");
			sb.append("acountId:").append(tradeAcount.getAcountId()).append("  asofdate:")
					.append(summary.getId().getAsofdate()).append("\n");
			sb.append("cash:").append(summary.getCash()).append(" marketValue:").append(summary.getMarketValue());
			sb.append("\n");
			return sb.toString();
		} catch (Exception e) {
			return e.getMessage();
		}
	}
}
